import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';

import { getDictOptions } from '#/utils/dict';

// 查询条件表单配置
export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'categoryName',
    label: '分类名称',
  },
  {
    component: 'TreeSelect',
    fieldName: 'parentId',
    label: '父级分类',
    componentProps: {
      placeholder: '请选择父级分类',
      treeData: [],
      fieldNames: { label: 'categoryName', value: 'categoryId' },
      treeDefaultExpandAll: true,
      treeLine: { showLeafIcon: false },
      treeNodeLabelProp: 'fullName',
      showSearch: true,
    },
  },
  {
    component: 'Select',
    componentProps: {
      options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
    },
    fieldName: 'status',
    label: '状态',
  },
  {
    component: 'RangePicker',
    fieldName: 'createTime',
    label: '创建时间',
  },
];

// 表格列配置
export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '序号',
    field: 'orderNum',
    width: 80,
    align: 'center',
  },
  {
    title: '分类名称',
    field: 'categoryName',
    minWidth: 150,
  },
  {
    title: '分类描述',
    field: 'categoryDescription',
    minWidth: 200,
  },
  {
    title: '状态',
    field: 'status',
    slots: { default: 'status' },
    width: 100,
  },
  {
    title: '创建时间',
    field: 'createTime',
    width: 160,
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 160,
  },
];
